#include<iostream>
#include<string>
#include<vector>

int spit(const std::string &str,const std::string &sep,std::vector<std::string>*array)
{
    int count=0;
    size_t pos=0,idx=0;
    while(1)
    {
      pos=str.find(sep,idx);
      if(pos==std::string ::npos)
         {
          break;
      
         }
      if(pos==idx){
       idx=pos+sep.size();
       continue;
                               " | | | |ser |der |ser"

      }

      std::string tmp=str.substr(idx,pos-idx);
      array->push_back(tmp);
      count++;
      idx=pos+sep.size();
    }
      if(idx<str.size())
         {
             array->push_back(str.substr(idx));
             count++;
         }

      return count;

}
int main()
{

std::string str="    what  can       i       say";
std::vector<std::string>array;
spit(str," ",&array);
for(auto e:array)
{std::cout<<e<<std::endl;}

}
